#include "widget.h"
#include "ui_widget.h"
#include <QRegExpValidator>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    //基于正则表达式验证手机号码
    QRegExp regExp("^1\\d{10}$");//表示以1开头,数字出现10次,$表示结尾
    ui->lineEdit->setValidator(new QRegExpValidator(regExp));
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_clicked()
{

}

void Widget::on_lineEdit_textEdited(const QString &text)
{
    QString content=text;
    int pos=0;
    if(ui->lineEdit->validator()->validate(content,pos)==QValidator::Acceptable)
        ui->pushButton->setEnabled(true);
    else ui->pushButton->setEnabled(false);
}
